function OPENRESPONSE(xmlDoc) {
  this.xmlDoc = xmlDoc;
  this.promptText = this.xmlDoc.getElementsByTagName('prompt')[0].firstChild.nodeValue;
  this.expectedLines = this.xmlDoc.getElementsByTagName('extendedTextInteraction')[0].getAttribute('expectedLines');
}

/**
 * Saves current state of the OpenResponse item
 * - what the students typed
 * - timestamp
 * 
 * Then disable the textarea and save button and show the edit button
 */
OPENRESPONSE.prototype.save = function() {
	var isSaveDisabled = hasClass("saveButton", "disabledLink");

	if (!isSaveDisabled) {
		states.push(new OPENRESPONSESTATE(document.getElementById('responseBox').value));
		removeClassFromElement("editButton", "disabledLink");
		addClassToElement("saveButton", "disabledLink");
		setResponseBoxEnabled(false);
	}
}

/**
 * Edits current state of the OpenResponse item
 * 
 * Enable textarea and save button, hide the edit button
 */
OPENRESPONSE.prototype.edit = function() {
	var isEditDisabled = hasClass("editButton", "disabledLink");

	if (!isEditDisabled) {
		removeClassFromElement("saveButton", "disabledLink");
		addClassToElement("editButton", "disabledLink");
		setResponseBoxEnabled(true);
		displayNumberAttempts("This is your", "revision");
	}
}

/**
 * Render this OpenResponse item
 */
OPENRESPONSE.prototype.render = function() {
	
	// render the prompt
	var promptdiv = document.getElementById('promptDiv');
	promptdiv.innerHTML=this.promptText;

	// set text area size: set row based on expectedLines
	document.getElementById('responseBox').setAttribute('rows', this.expectedLines);
	displayNumberAttempts("This is your", "revision");
	addClassToElement("editButton", "disabledLink");
	
}